ShortKey.DataAccess = { db = nil }

local DataAccess = ShortKey.DataAccess

function DataAccess:Load()
	if (ShortKeyDB) then
		self.db = ShortKeyDB

		if (self.db.Setting) then
			if (self.db.Setting.IsAutoLoad ~= nil) then
				ShortKey.Setting.IsAutoLoad = self.db.Setting.IsAutoLoad
			end

			if (self.db.Setting.IsAutoSelect ~= nil) then
				ShortKey.Setting.IsAutoSelect = self.db.Setting.IsAutoSelect
			end

			if (self.db.Setting.IsShowSelected ~= nil) then
				ShortKey.Setting.IsShowSelected = self.db.Setting.IsShowSelected
			end
		end

		ShortKey.OutsideConfig.SelectedGroup
	end
end

function DataAccess:Save()
	ShortKeyDB = ShortKeyDB or {}
	ShortKeyDB.IsAutoLoad = ShortKey.Setting.IsAutoLoad
	ShortKeyDB.IsAutoSelect = ShortKey.Setting.IsAutoSelect
	ShortKeyDB.IsShowSelected = ShortKey.Setting.IsShowSelected
	ShortKeyDB.SelectedGroup = ShortKey.Setting.SelectedGroup
end

function DataAccess:Clear()
	self.db:ClearAll()
end

function DataAccess:ClearSetting()
	self.db:Clear(ShortKey.Setting)
end

function DataAccess:ClearSetting()
	ShortKeyDB = nil
	print("ShortKey setting is cleared, you need to reload UI.")
end